package com.yubest.disruptor;

import com.lmax.disruptor.RingBuffer;

public class MsgEventProducer {

    private final RingBuffer<MsgEvent> ringBuffer;

    public MsgEventProducer(RingBuffer<MsgEvent> ringBuffer) {
        this.ringBuffer = ringBuffer;
    }

    public void onData(Msg msg) {
        ringBuffer.publishEvent((target, sequence, source) -> {
            target.setType(source.getType());
            target.setMsg(source.getMsg());
        }, msg);
    }
}
